<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<html>
<head>
    <title>${param.category} - 教育新闻网</title>
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .news-list {
            margin: 30px 0;
        }
        .news-item {
            padding: 20px;
            border-bottom: 1px solid #eee;
            transition: all 0.3s;
        }
        .news-item:hover {
            background-color: #f8f9fa;
            transform: translateX(10px);
        }
        .news-title {
            color: #333;
            font-size: 18px;
            margin-bottom: 10px;
            text-decoration: none;
        }
        .news-title:hover {
            color: #0d6efd;
        }
        .news-meta {
            color: #666;
            font-size: 14px;
        }
        .news-meta span {
            margin-right: 20px;
        }
        .pagination {
            margin-top: 30px;
            justify-content: center;
        }
    </style>
</head>
<body>
    <!-- 引入头部 -->
    <jsp:include page="/user/common/header.jsp"/>
    
    <div class="container">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="${pageContext.request.contextPath}/user/home">首页</a></li>
                <li class="breadcrumb-item active">${param.category}</li>
            </ol>
        </nav>
        
        <div class="news-list">
            <c:forEach items="${newsList}" var="news">
                <div class="news-item">
                    <a href="${pageContext.request.contextPath}/user/news/detail?id=${news.newsId}" class="news-title">
                        ${news.title}
                    </a>
                    <div class="news-meta">
                        <span><i class="bi bi-eye"></i> ${news.viewCount}次浏览</span>
                        <span><i class="bi bi-clock"></i> <fmt:formatDate value="${news.createTime}" pattern="yyyy-MM-dd HH:mm"/></span>
                    </div>
                </div>
            </c:forEach>
        </div>
        
        <!-- 分页 -->
        <c:if test="${totalPages > 1}">
            <nav>
                <ul class="pagination">
                    <li class="page-item ${currentPage == 1 ? 'disabled' : ''}">
                        <a class="page-link" href="${pageContext.request.contextPath}/user/news?category=${param.category}&page=${currentPage - 1}">上一页</a>
                    </li>
                    
                    <c:forEach begin="1" end="${totalPages}" var="i">
                        <li class="page-item ${currentPage == i ? 'active' : ''}">
                            <a class="page-link" href="${pageContext.request.contextPath}/user/news?category=${param.category}&page=${i}">${i}</a>
                        </li>
                    </c:forEach>
                    
                    <li class="page-item ${currentPage == totalPages ? 'disabled' : ''}">
                        <a class="page-link" href="${pageContext.request.contextPath}/user/news?category=${param.category}&page=${currentPage + 1}">下一页</a>
                    </li>
                </ul>
            </nav>
        </c:if>
    </div>
    
    <!-- 引入底部 -->
    <jsp:include page="/user/common/footer.jsp"/>
    
    <script src="${pageContext.request.contextPath}/static/js/bootstrap.bundle.min.js"></script>
</body>
</html> 